﻿// Decompiled with JetBrains decompiler
// Type: BUTR.DependencyInjection.GenericServiceProvider
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

#nullable enable
namespace BUTR.DependencyInjection
{
  public static class GenericServiceProvider
  {
    internal static IGenericServiceProvider? GlobalServiceProvider;
    internal static IGenericServiceProviderScope? GameScopeServiceProvider;

    public static TService? GetService<TService>() where TService : class
    {
      if (GenericServiceProvider.GameScopeServiceProvider != null)
        return GenericServiceProvider.GameScopeServiceProvider.GetService<TService>();
      IGenericServiceProvider globalServiceProvider = GenericServiceProvider.GlobalServiceProvider;
      return globalServiceProvider == null ? default (TService) : globalServiceProvider.GetService<TService>();
    }

    public static IGenericServiceProviderScope? CreateScope()
    {
      return GenericServiceProvider.GlobalServiceProvider?.CreateScope();
    }
  }
}
